function [E_hat,Select] = func_LocalReg(response,X,n,p,h,weight,lambda,K)

    E_hat = mean(response)*ones(n,1); 

    for k=1:K    
        Xi_phi = max(eps,sqrt(h*mean((repmat(weight.*(response-E_hat),[1,p]).*X).^2,1)));
        [B,FitInfo] = lassoglm(X/diag(Xi_phi),response,'normal','Link','identity','Lambda',2*lambda/(n*h),'Weights',weight/n,'Standardize',0);                    
        E_hat = FitInfo.Intercept+(X/diag(Xi_phi))*B;            
    end
    
    Select = B~=0;
                       
end

